var mysql = require('mysql');
var conn = mysql.createConnection({
	host: 'localhost',
	port: 3306,
	user: 'root',
	password: 'root',
	database: 'test',	multipleStatements: true
});

conn.connect();

// conn.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
// 	if (err) throw err;

// 	console.log('The solution is: ', rows[0].solution);
// });
// // drop table if exists " + table
// conn.query('drop database if  exists test;',function  (err,rows,fields) {
// 	if(err)throw err;
// 	console.log(err,rows,fields);
// })
// conn.query('create database test;',function  (err,rows,fields) {
// 	if(err)throw err;
// 	console.log(err,rows,fields);
// })
// conn.query('use test;',function  (err,rows,fields) {
// 	if(err)throw err;
// 	console.log(err,rows,fields);
// })
conn.query('drop table if exists user ',function  (err,rows,fields) {
	if(err)throw err;
	console.log(err,rows,fields);
})
conn.query('create table user(id int auto_increment primary key ,name varchar(255),age int ,intro text)',function  (err,rows,fields) {
	if(err)throw err;
	console.log(err,rows,fields);
})

conn.query('insert into user (name,age,intro) values("wang",2,"wangIntro")', function(err, rows, fields) {
	if (err) throw err;
	console.log(rows);
})

conn.query('select * from user', function(err, rows) {
	if (err) throw err;
	console.log(rows);
})

conn.query('update user set age=age+10 ', function(err, rows) {
	if (err) throw err;
	console.log(rows);
})


conn.end();


